import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',//url路径
    name: 'Home',//路由名称 后面有用
    component: Home//路由跳转后展示的组件页面
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/elementui',
    name: 'Myhome',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '@/views/myhome.vue'),
    // 二级路由配置
    children:[
      {
        path: '/userinfo',
        name: 'Userinfo',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/userinfo.vue'),
        //三级路由
        children:[
          {
            path: '/userinfo/showpage',
            name: 'Showpage',
            // route level code-splitting
            // this generates a separate chunk (about.[hash].js) for this route
            // which is lazy-loaded when the route is visited.
            component: () => import(/* webpackChunkName: "about" */ '../components/page.vue')
          },
        ]
      }
    ]
  },
  {
    path: '/one/',
    name: 'One',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/onerouter/onerouterview.vue'),
    children:[
      {
         // params动态路由参数  url:/one/1    在下面path后面加:userid
        path: '/two/:userid',
        name: 'Two',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/onerouter/tworouter/tworouterview.vue'),
        children:[
          {
            // 以query模式 /two/userid=1  啥都不用改！
            path: '/third',
            name: 'Third',
            // route level code-splitting
            // this generates a separate chunk (about.[hash].js) for this route
            // which is lazy-loaded when the route is visited.
            component: () => import(/* webpackChunkName: "about" */ '../views/onerouter/tworouter/thirdrouter/thirdrouterview.vue'),
          }
        ]
      },
    ]
  },
]

const router = new VueRouter({
  routes
})

export default router
